

package top.continew.admin.question.user.service.question.entity;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;
import top.continew.admin.question.model.question.Question;
import top.continew.admin.question.user.service.question.enums.QuestionTypeEnum;
import top.continew.admin.question.user.service.question.factory.QuestionFactory;

import java.util.List;

@Data
public class MaterialQuestion extends AbstractQuestion {

    //子题目
    private List<AbstractQuestion> subQuestion;

    @Override
    public void init(Question question) {
        super.init(question);
        List<Question> subQuestions = new Question().selectList(Wrappers.lambdaQuery(Question.class)
            .eq(Question::getParentId, question.getId())
            .orderByAsc(Question::getSort));
        subQuestion = subQuestions.stream().map(QuestionFactory::createQuestion).toList();
    }

    @Override
    public CorrectResult correct(String userAnswer) {
        return null;
    }

    @Override
    public Integer getType() {
        return QuestionTypeEnum.MATERIAL_QUESTIONS.getCode();
    }

    @Override
    public String getTypeName() {
        return QuestionTypeEnum.MATERIAL_QUESTIONS.getName();
    }
}